/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */


package com.smg.community.controller;


import java.util.List;

import javax.servlet.http.HttpServletRequest;

import javacommon.base.BaseRestSpringController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.org.rapid_framework.page.Page;

import com.smg.community.model.*;
import com.smg.community.service.CityManager;
import com.smg.community.vo.query.MemMemberQuery;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */

@Controller
@RequestMapping("/memmember")
public class MemMemberController extends BaseRestSpringController<MemMember,java.lang.Long>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	@RequestMapping(value="/list")
	public String  list(HttpServletRequest request,ModelMap model){
		CrmUser loginUser = getLoginUser(request);
		String userCityNos = loginUser.getCityNo();
		if  ( userCityNos == null ||  userCityNos.length() == 0 ){
			model.addAttribute("message","用户不拥有任何城市");
			return "/common/error";
		}
		List<City> cityList = CityManager.getCityListByUserCityNos(userCityNos);
		model.addAttribute("cityList",cityList);
		userCityNos = userCityNos.substring(0);
		userCityNos = userCityNos.substring(1,userCityNos.length()-1);
		model.addAttribute("userCityNos",userCityNos);
		return "/memmember/list";
	}
	
	@RequestMapping(value="/getpagedata")
	public    @ResponseBody ExtJsPageData<MemMember> getListData(MemMemberQuery query){
		@SuppressWarnings("unchecked")
		Page<MemMember> page   = memMemberManager.findPage(query);
		return transToExtJsPageData(page.getResult(),page.getTotalCount());
	}

	
}

